package com.huawei.appgallery.search.ui.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.animation.Interpolator;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import o.cjy;
import o.cjy.d;
import o.cuv.j;
import o.cux;

@SuppressLint({"ClickableViewAccessibility"})
public class HorizontalTextRecyclerView extends RecyclerView implements d {
    private cjy ˏˏ = null;
    private boolean ͺॱ = false;
    private Interpolator ـ;
    private boolean ॱʻ = false;
    private float ॱʼ = 0.0f;
    private a ॱʽ;
    private float ॱͺ = 0.0f;

    public interface a {
        void ˊ();
    }

    public HorizontalTextRecyclerView(Context context) {
        super(context);
        ॱ(null);
        ˎˏ();
    }

    public HorizontalTextRecyclerView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        ॱ(attributeSet);
        ˎˏ();
    }

    public HorizontalTextRecyclerView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ॱ(attributeSet);
        ˎˏ();
    }

    private void ˎˏ() {
        this.ـ = new d(null);
    }

    public void ˊ(int i, int i2) {
        super.ˊ(i, i2, this.ـ);
    }

    private void ॱ(AttributeSet attributeSet) {
        if (attributeSet != null) {
            TypedArray typedArray = null;
            try {
                typedArray = getContext().obtainStyledAttributes(attributeSet, j.ॱㆍ);
                this.ͺॱ = typedArray.getBoolean(j.ॱᐨ, false);
                if (typedArray != null) {
                    typedArray.recycle();
                }
            } catch (RuntimeException e) {
                cux.ˏ.ˊ("HorizontalTextRecyclerView", "init(AttributeSet attrs) " + e.toString());
                if (typedArray != null) {
                    typedArray.recycle();
                }
            } catch (Throwable th) {
                if (typedArray != null) {
                    typedArray.recycle();
                }
            }
        }
        if (this.ͺॱ) {
            this.ˏˏ = new cjy((RecyclerView) this);
        }
    }

    public boolean dispatchTouchEvent(MotionEvent motionEvent) {
        switch (motionEvent.getAction()) {
            case 0:
                this.ॱʼ = motionEvent.getY();
                this.ॱͺ = motionEvent.getX();
                break;
            case 2:
                if (ˏ(motionEvent) < ॱ(motionEvent)) {
                    this.ॱʻ = false;
                    if (getParent() != null) {
                        getParent().requestDisallowInterceptTouchEvent(false);
                        break;
                    }
                }
                if (getParent() != null) {
                    getParent().requestDisallowInterceptTouchEvent(true);
                }
                this.ॱʻ = true;
                return super.dispatchTouchEvent(motionEvent);
                break;
        }
        return super.dispatchTouchEvent(motionEvent);
    }

    public int ॱ(@NonNull MotionEvent motionEvent) {
        return Math.abs((int) (motionEvent.getY() - this.ॱʼ));
    }

    public int ˏ(@NonNull MotionEvent motionEvent) {
        return Math.abs((int) (motionEvent.getX() - this.ॱͺ));
    }

    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        if (this.ॱʻ && getParent() != null) {
            getParent().requestDisallowInterceptTouchEvent(true);
        }
        if (this.ͺॱ && this.ˏˏ != null) {
            this.ˏˏ.ˋ(motionEvent);
        }
        try {
            return super.onInterceptTouchEvent(motionEvent);
        } catch (IllegalArgumentException e) {
            return false;
        }
    }

    public boolean onTouchEvent(MotionEvent motionEvent) {
        if (this.ॱʻ && getParent() != null) {
            getParent().requestDisallowInterceptTouchEvent(true);
        }
        try {
            if (motionEvent.getAction() == 1 && this.ॱʽ != null) {
                this.ॱʽ.ˊ();
            }
            if (this.ͺॱ && this.ˏˏ != null && this.ˏˏ.ˏ(motionEvent)) {
                return true;
            }
            return super.onTouchEvent(motionEvent);
        } catch (IllegalArgumentException e) {
            cux.ˏ.ˊ("HorizontalTextRecyclerView", "onTouchEvent(MotionEvent ev)  " + e.toString());
            return false;
        }
    }

    public boolean ˌ() {
        return !canScrollHorizontally(-1);
    }

    public boolean ˋˋ() {
        return !canScrollHorizontally(1);
    }

    public boolean ˎˎ() {
        return false;
    }

    public boolean ˋᐝ() {
        return false;
    }

    public void setTouchListener(a aVar) {
        this.ॱʽ = aVar;
    }
}
